<?php

namespace App\Modules\CodeDesigner\Memento;

// 备忘录  用来存储originator对象的内部状态
class MementoImpl implements MementoInterface
{

    private $state;

    private $date;

    public function __construct(string $state)
    {
        $this->state = $state;
        $this->date = date('Y-m-d H:i:s');
    }

    public function getState(): string
    {
        return $this->state;
    }

    public function getDate(): string
    {
        return $this->date;
    }

    public function getName(): string
    {
        return $this->date . " / (" . substr($this->state, 0, 9) . "...)";
    }
}